package org.java.item.web;

import org.java.common.vo.ResultVo;
import org.java.item.entity.Brand;
import org.java.item.service.BrandService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author WHQ
 * @version 1.0
 * @date 2022-3-5 0005 下午 3:15
 */
@RestController
public class BrandController {

    @Resource
    BrandService brandService;

    /**
     * 网关访问地址:http://api.shopping.com/item/brand/list
     * @param page
     * @param limit
     * @return
     */
    @GetMapping("/brand/list")
    public ResponseEntity<ResultVo<Brand>> getList(Integer page,Integer limit){
        System.out.println("进入查询品牌列表的方法");
        ResultVo<Brand> vo=brandService.getList(page,limit);
        return ResponseEntity.ok(vo);
    }

    /**
     * 删除品牌的方法
     * 网关地址:http://api.shopping.com/item/brand/del/{id}
     * @param id
     * @return
     */
    @DeleteMapping("/brand/del/{id}")
    public ResponseEntity<Void> del(@PathVariable("id") Long id){
        System.out.println(id);
        brandService.del(id);
        return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
    }
}
